<template>
	<view>
		<view class="bg-white solid-top rowsb align-center padding" @click="$tools.Router('/pages/address/address')">
			<view class="margin-right align-center">
				<image src="/static/dingwei.png" mode="" class="" style="width: 30rpx;height: 30rpx;"></image>
				<view class="margin-left">
					<view>
						<text>{{addressData.name}}</text>
						<text class="text-gray margin-left">{{addressData.tel}}</text>
					</view>
					<view class="towlineshow">
						{{addressData.sca_name}}{{addressData.address}}
					</view>
				</view>
			</view>
			<view class="margin-left">
				<view class="arrow"></view>
			</view>
		</view>
		<view class=" bg-white margin-top-sm radius margin-sm">
			<view class="padding solid-bottom rowsb">
				<text>商品详情</text>
				<text class="text-gray">{{integralData.orderno}}</text>
			</view>
			<view class="margin-sm padding-bottom-sm rows">
				<view class="margin-right">
					<image :src="image+integralData.img" mode="" class="bg-gray radius" style="height: 150rpx;width: 150rpx;"></image>
				</view>
				<view>
					<view>{{integralData.title}}</view>
					<view class="flex ">
						<view class="bg-gray margin-top-sm text-sm" style="padding: 3rpx 10rpx;border-radius: 5rpx;">
							{{integralData.spec}}
						</view>
					</view>
					<view class=" rowsb margin-top-sm align-center" style="width: 200rpx;">
						<view>￥{{integralData.price}} </view>
						<view>X{{integralData.num}}</view>
					</view>
				</view>
			</view>
		</view>

		<view class="bg-white  margin-sm radius">
			<view class="rowsb solid-bottom padding padding-bottom">
				<text>商品金额</text>
				<text class="text-gray">￥{{integralData.price}}</text>
			</view>
			<view class="bg-white rowsb padding  padding-sm">
				<view>
					订单编号
				</view>
				<view class="">
					{{integralData.orderno}}
				</view>
			</view>
			<view class="bg-white rowsb padding  padding-sm">
				<view>
					下单时间
				</view>
				<view class="">
					{{integralData.add_time}}
				</view>
			</view>
			<view class="bg-white rowsb padding  padding-sm">
				<view>
					订单状态
				</view>
				<view class="text-red">
					{{orderNameList[integralData.status]}}
				</view>
			</view>
		</view>
		<view style="height: 130rpx;">

		</view>
		<view class="padding-sm bg-white rowsb align-center" style="position: fixed; z-index: 1;left: 0;right: 0;bottom: 0;">
			<view style="color: #DF1414;">
			</view>
			<view class="rows" @click="orderMen()">
				<view style="background: #DF1414;width: 130rpx; text-align: center;" class="text-white padding-tb-sm padding-lr-lg radius">
					确认收货
				</view>
			</view>
		</view>
		<view class="warp align-center rowsc" v-if="orderSet">
			<view class="margin-xl padding bg-gray radius" style="background-color: #FFFFFF;width: 70%;">
				<view class="text-center  padding-bottom border-bottom">
					<view class="text-bold">
						温馨提示
					</view>
					<view class="text-gray margin-top">确定已经收到货物？</view>
				</view>
				<view class="flex justify-around text-xl margin-top">
					<view class="solid-right" @click="orderSet=false">
						取消
					</view>
					<view class="" style="color: #007AFF;" @click="submitOrderDetail()">确定</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	const app = getApp().globalData
	import {
		getIntegralOrderInfo,
		confirmReceipt
	} from '../../../common/path.js'
	export default {
		data() {
			return {
				detailId: '',
				integralData: [],
				addressData: [],
				orderSet: false,
				constInfo: '', //退款原因
				status: '',
				image: '', //拼接
				orderNameList: [
					'',
					'待付款',
					'待发货',
					'待收货',
					'已完成'
				],
			}
		},
		onLoad(option) {
			this.detailId = option.id
			this.image = app.image
			this.getIntegralOrderInfo()
		},
		methods: {
			//获取积分订单详情接口
			getIntegralOrderInfo() {
				let data = {
					id: this.detailId
				}
				this.$axios.axios('POST', getIntegralOrderInfo, data)
					.then(res => {
						console.log('订单详情====>', res.data);
						try {
							if (res.status == 1) {
								this.integralData = res.data
								this.addressData = res.data.address
							} else {
								this.$tools.showToast('请检查网络连接')
							}
						} catch (e) {
							this.$tools.showToast('请检查网络连接')
						}
					})
					.catch(err => {
						this.$tools.showToast('请检查网络连接')
					})

			},
			//确认收货处理
			orderMen() {
				if (this.integralData.status == 3) {
					this.orderSet = true
				} else {
					this.$tools.showToast('该商品还未发货请耐心等待....')
				}

			},
	


			submitOrderDetail() {
				this.orderSet = false
				let data = {
					id:this.detailId
				}
				this.$axios.axios("POST",confirmReceipt,data)
					.then(res => {
						if(res.status == 1){
							setTimeout(res => {
								this.$tools.navigateBack()
							}, 1000)
							this.$tools.showToast2('操作成功!')
						}else{
							this.$tools.showToast(res.msg)
						}
					})
					.catch(err => {
						console.log(err)
					})
			},

		}
	}
</script>

<style>
</style>
